#include "MkHttpApi/MkHttpApi.h"
#include "MkEvent/MkEvent.h"
#include "MkHttp/MkHttpRequest.h"
#include "MkHttp/MkHttpUri.h"
#include "MkHttp/MkHttpSession.h"
#include "MkHttp/MkWebSocketMessage.h"
#include "MkUtil/MkBase64.h"
#include "MkUtil/MkLog.h"
#include "MkUtil/MkUtil.h"
#include "MkSampleHttpApiServer.h"
#include "MkEvent/MkEventPool.h"

CComHttpServer::CComHttpServer(CMkEventPool* pEventPool, CMkTimer* pTimer)
    : CMkHttpApi(pEventPool,pTimer)
{
}

Uint32 CComHttpServer::OnRequestJsonParse(const MkHttpMethod& Method, const MkString& Path, const MkMapString& MapQuery, const Json::Value& JsonReq, const MkHttpResponseJsonCb& cb)
{
    cb(NoneError, Json::Value());
    return NoneError;
}

CComHttpServer::~CComHttpServer()
{

}

int main(int argc, char ** argv)
{
#ifdef _WIN32
    WSADATA WSAData;
    WSAStartup(0x101, &WSAData);
#endif
    MkLogChangeLevel(LOG_DEBUG);
    CMkEventPool Pool;
    Uint32 ErrorCode = Pool.Start();
    if (NoneError != ErrorCode) {
        MkErrorLog("start event pool failed\n");
        return 0;
    }
    CMkTimer Timer;
    CComHttpServer Svr(&Pool, &Timer);
    Svr.SetUserPass("admin", "admin");
    Svr.StartServer(58082);
    MkDebugLog("start server:%d\n", 58082);
    Timer.Dispatch();
#ifdef _WIN32
    WSACleanup();
#endif
}

